<?php
$url=@$_POST['url'];
$ki=@$_POST['ki'];
set_time_limit(0);
$url=str_replace(" ","",$url);
include "htmlD/simple_html_dom.php";
//$url='http://me.zing.vn/u/langthangdemdem';
//$dom = new domDocument;
$link=file_get_html($url);
//@$dom->loadHTML($link);
//$dom->preserveWhiteSpace = false;
//$ki="img";
if($ki=="title")
{
	$title = trim($link->find('title', 0)->plaintext); 
	foreach ($link->find('meta[name=description]') as $e)
	$meta = $e->content;
	if($meta=="")
	$meta="Mô tả chi tiết";
	
	
	$B=array(
	'title' => $title,
	'link' => $url,
	'meta' => $meta
	);
	//$B=array('test' => '12345');
	echo json_encode($B);
	//echo 'aaaa';
}
else if ($ki=="img")
{
	//$image=$dom->getElementsByTagName('img');
	$arr_img=array();
	$i=0;
	foreach($link->find('img') as $e)
	{
		
		//$url_image=$e->src;
		
		//&& strlen(strstr($url_image,"banner"))==0
		if(strlen(strstr($e->src,"http://"))>0)
		{
		//echo "<br>".$e->getAttribute('width')."__";
		//$arr_img[]=$e->src;
		
			$img_size=getimagesize($e->src);
			if($img_size[0]>100 && $img_size[1]>100)
			{//echo $e->src;
				$i++;
				//array_push($arr_img,$url_image);
				$arr_img[]=$e->src;
			}
		}
		//if($i==10)
		//break;
	}
		$B=array(
		'img' => $arr_img
		);
	echo json_encode($B);
}


?>